import QtQuick 2.15

// MyWidget.qml
import QtQuick 2.0
import QtQuick.Controls 2.15

Rectangle {
    id: widget
    color: "lightsteelblue"
    width: 175
    height: 25
    radius: 10
    antialiasing: true

    // 可自定义的属性
    property alias text: label.text

    Text {
        id: label
        anchors.centerIn: parent
    }

    focus: true
    Keys.onPressed: (event)=> {
        if (event.key === Qt.Key_A){
            label.text = 'Key A was pressed'
        }else if (event.key === Qt.Key_B){
            label.text = 'Key B was pressed'
        }else if (event.key === Qt.Key_C){
            label.text = 'Key C was pressed'
        }
        customSignal( label.text  )
    }

    // 自定义信号
    signal customSignal(string message)
}
